<?php

namespace app\api\Controller;

use think\Controller;

class Pic extends Controller{
		public function Pic(){
		
		}

		public function wx(){
			
        return $this->fetch();
		}
		function post_http($url,$data){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // post数据
        curl_setopt($ch, CURLOPT_POST, 1);
        // post的变量
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        $output = curl_exec($ch);
        curl_close($ch);
        //打印获得的数据
        return  $output;
    }
    public function wx1(){
		$input=input('param.');
		//var_dump($input);
        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$input['appid']."&secret=".$input['secret'];
                //2、初始化
        //$token=$this->http_curl($url);
        $access_token = $this->http_curl($url);
        //var_dump($access_token);
        echo json_encode($access_token);
		}
	function http_curl($url){
        $ch = curl_init();
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        $res=json_decode(curl_exec($ch),true);
        curl_close($ch);
       return  $res;
    }
}



